*Replication Syntax for "Working-Class Legislators and Perceptions of Representation in Latin America"
*Tiffany D. Barnes and Gregory W. Saxton
*Do-file crated January 17, 2019


capture log close
use PRQ_BarnesSaxton.dta, clear

version 15

*labels for table
label variable pers_vote "Personal Vote Seeking"
label variable pid_left "%Left Party in Legislature"
label variable lid_left "% Left Party (Self-Placement)"
label variable pres_ideo "Left-President"
label variable gni "GNI per capita"
label variable v_worker "Working Class Citizen"
label variable ed "Education"
label variable pol_intr "Political Interest"
label variable income_full "Income"
label variable female "Female"
label define ideology5 1 "Ideology=Left (1-3)" 2 "Ideology=4-5" 3 "Ideology=6-7" 4 "Ideology=Right (8-10)" 0 "Ideology=None", replace
	label values ideology5 ideology5
label variable age "Age"
label variable rural "Rural"
label variable econ_worse "Economic Perception (Worse)"
label variable workers "% Workers in Legislature"

//Table 1 Working-Class Legislators and Perceptions of Legislative Representation 
meologit leg_approve workers pers_vote pid_left gni  ed pol_intr income_full female i.b0.ideology5 age rural econ_worse i.married if year<=2010 || cyear:, covar(un)
meologit leg_approve c.workers##i.v_worker pers_vote pid_left gni  ed pol_intr income_full female i.b0.ideology5 age rural econ_worse i.married  || cyear:, covar(un)
meologit b13 workers  pers_vote pid_left gni  ed pol_intr  income_full female i.b0.ideology5 age rural econ_worse i.married if year<=2010 || cyear:, covar(un)
meologit b13 c.workers##i.v_worker  pers_vote pid_left gni  ed pol_intr  income_full female i.b0.ideology5 age rural econ_worse i.married || cyear:, covar(un)
meologit ec4 workers  pers_vote pid_left gni ed pol_intr income_full female i.b0.ideology5 age rural econ_worse i.married if year<=2010 || cyear:, covar(un)
meologit ec4 c.workers##i.v_worker pers_vote pid_left gni  ed pol_intr income_full female i.b0.ideology5 age rural econ_worse i.married || cyear:, covar(un)

//Figure 1: Perceptions of Legislative Representation in Latin America
meologit leg_approve workers pers_vote pid_left gni  ed pol_intr income_full female i.b0.ideology5 age rural econ_worse i.married if year<=2010
hist leg_approve if e(sample)
meologit b13 workers  pers_vote pid_left gni  ed pol_intr  income_full female i.b0.ideology5 age rural econ_worse i.married if year<=2010 || cyear:, covar(un)
hist b13 if e(sample)
meologit ec4 workers  pers_vote pid_left gni ed pol_intr income_full female i.b0.ideology5 age rural econ_worse i.married if year<=2010 || cyear:, covar(un)
hist ec4 if e(sample)

//Figure 4: Marginal Effect of Percent Workers on Predicted Satisfaction with Representation
meologit leg_approve c.workers##i.v_worker pers_vote pid_left gni  ed pol_intr income_full female i.b0.ideology5 age rural econ_worse i.married || cyear:, covar(un)
margins, at(v_worker=(1 0)) dydx(workers) predict(outcome(1))
margins, at(v_worker=(1 0)) dydx(workers) predict(outcome(2))
margins, at(v_worker=(1 0)) dydx(workers) predict(outcome(4))
margins, at(v_worker=(1 0)) dydx(workers) predict(outcome(5))

meologit b13 c.workers##i.v_worker pers_vote pid_left gni  ed pol_intr income_full female i.b0.ideology5 age rural econ_worse i.married || cyear:, covar(un)
margins, at(v_worker=(1 0)) dydx(workers) predict(outcome(1))
margins, at(v_worker=(1 0)) dydx(workers) predict(outcome(2))
margins, at(v_worker=(1 0)) dydx(workers) predict(outcome(6))
margins, at(v_worker=(1 0)) dydx(workers) predict(outcome(7))

meologit ec4 c.workers##i.v_worker pers_vote pid_left gni  ed pol_intr income_full female i.b0.ideology5 age rural econ_worse i.married || cyear:, covar(un)
margins, at(v_worker=(1 0)) dydx(workers) predict(outcome(1))
margins, at(v_worker=(1 0)) dydx(workers) predict(outcome(2))
margins, at(v_worker=(1 0)) dydx(workers) predict(outcome(6))
margins, at(v_worker=(1 0)) dydx(workers) predict(outcome(7))

//Figure 5: Working-Class Legislators and Preceptions of Legislative Representation
meologit leg_approve workers pers_vote pid_left gni  ed pol_intr income_full female i.b0.ideology5 age rural econ_worse i.married if year<=2010|| cyear:, covar(un);
margins, at(worker=(0 1 2.1 3.1 4.12 5.51 6.36 11.54 12.19 16.67)) predict(outcome(1))	
margins, at(worker=(0 1 2.1 3.1 4.12 5.51 6.36 11.54 12.19 16.67)) predict(outcome(2))	
margins, at(worker=(0 1 2.1 3.1 4.12 5.51 6.36 11.54 12.19 16.67)) predict(outcome(4))
margins, at(worker=(0 1 2.1 3.1 4.12 5.51 6.36 11.54 12.19 16.67)) predict(outcome(5))
	
meologit b13 workers pers_vote pid_left gni  ed pol_intr income_full female i.b0.ideology5 age rural econ_worse i.married if year<=2010 || cyear:, covar(un);
margins, at(worker=(0 1 2.1 3.1 4.12 5.51 6.36 11.54 12.19 16.67)) predict(outcome(1))
margins, at(worker=(0 1 2.1 3.1 4.12 5.51 6.36 11.54 12.19 16.67)) predict(outcome(2))
margins, at(worker=(0 1 2.1 3.1 4.12 5.51 6.36 11.54 12.19 16.67)) predict(outcome(6))
margins, at(worker=(0 1 2.1 3.1 4.12 5.51 6.36 11.54 12.19 16.67)) predict(outcome(7))
	
	
meologit ec4 workers pers_vote pid_left gni  ed pol_intr income_full female i.b0.ideology5 age rural econ_worse i.married if year<=2010 || cyear:, covar(un);
margins, at(worker=(0 1 2.1 3.1 4.12 5.51 6.36 11.54 12.19 16.67)) predict(outcome(1))
margins, at(worker=(0 1 2.1 3.1 4.12 5.51 6.36 11.54 12.19 16.67)) predict(outcome(2))
margins, at(worker=(0 1 2.1 3.1 4.12 5.51 6.36 11.54 12.19 16.67)) predict(outcome(6))
margins, at(worker=(0 1 2.1 3.1 4.12 5.51 6.36 11.54 12.19 16.67)) predict(outcome(7))
	

//Figure 3 and Appendix Table B8 Bivariate Relationship, Working-Class and Perceptions of Representation
meologit leg_approve workers if year<=2010 || cyear:, covar(un)
meologit b13 workers if year<=2010 || cyear:, covar(un)
meologit ec4 workers if year<=2010 || cyear:, covar(un)
*use bivariate models from collapsed data to create Figure 3
collapse (mean) workers leg_approve b13 ec4 if year<=2010, by(pais year)
regress leg_approve workers
regress b13 workers
regress ec4 workers


//Supplemental Analysis: Appendix A
//Table A5 Correlation between Percent Workers and Country-Level Variables
use PRQ_BarnesSaxton.dta, clear

//Correlations between all level2 variables (individual-level data)
meologit b13 workers if year<=2010 || cyear:, covar(un)
corr workers pers_vote gni lid_left pid_left pres_ideo democracy wgi psi_vdem if e(sample)

*collapsed data (country-year correlations)
collapse (mean) workers pers_vote gni lid_left pid_left pres_ideo democracy wgi psi_vdem cyear if e(sample), by(pais year)
corr workers pers_vote gni lid_left pid_left pres_ideo democracy wgi psi_vdem 

//Supplemental Analysis: Appendix B
use PRQ_BarnesSaxton.dta, clear

//Figure B1 Working-Class Representation and Legislative Approval
meologit leg_approve c.workers##i.v_worker  pers_vote pid_left gni  ed pol_intr income_full female i.b0.ideology5 age rural econ_worse i.married || cyear:, covar(un);
	margins if v_worker==1, at(worker=(0 1 2.1 3.1 4.12 5.51 6.36 11.54 12.19 16.67)) predict(outcome(1))
	margins if v_worker==1, at(worker=(0 1 2.1 3.1 4.12 5.51 6.36 11.54 12.19 16.67)) predict(outcome(2))
	margins if v_worker==1, at(worker=(0 1 2.1 3.1 4.12 5.51 6.36 11.54 12.19 16.67)) predict(outcome(3))
	margins if v_worker==1, at(worker=(0 1 2.1 3.1 4.12 5.51 6.36 11.54 12.19 16.67)) predict(outcome(4))
	margins if v_worker==1, at(worker=(0 1 2.1 3.1 4.12 5.51 6.36 11.54 12.19 16.67)) predict(outcome(5))
	
	margins if v_worker==0, at(worker=(0 1 2.1 3.1 4.12 5.51 6.36 11.54 12.19 16.67)) predict(outcome(1))
	margins if v_worker==0, at(worker=(0 1 2.1 3.1 4.12 5.51 6.36 11.54 12.19 16.67)) predict(outcome(2))
	margins if v_worker==0, at(worker=(0 1 2.1 3.1 4.12 5.51 6.36 11.54 12.19 16.67)) predict(outcome(3))
	margins if v_worker==0, at(worker=(0 1 2.1 3.1 4.12 5.51 6.36 11.54 12.19 16.67)) predict(outcome(4))
	margins if v_worker==0, at(worker=(0 1 2.1 3.1 4.12 5.51 6.36 11.54 12.19 16.67)) predict(outcome(5))
		
*Figure B2 Working-Class Representation and Legislative Trust
meologit b13 c.workers##i.v_worker  pers_vote pid_left gni  ed pol_intr income_full female i.b0.ideology5 age rural econ_worse i.married || cyear:, covar(un);
	margins if v_worker==1, at(worker=(0 1 2.1 3.1 4.12 5.51 6.36 11.54 12.19 16.67)) predict(outcome(1))
	margins if v_worker==1, at(worker=(0 1 2.1 3.1 4.12 5.51 6.36 11.54 12.19 16.67)) predict(outcome(2))
	margins if v_worker==1, at(worker=(0 1 2.1 3.1 4.12 5.51 6.36 11.54 12.19 16.67)) predict(outcome(3))
	margins if v_worker==1, at(worker=(0 1 2.1 3.1 4.12 5.51 6.36 11.54 12.19 16.67)) predict(outcome(4))
	margins if v_worker==1, at(worker=(0 1 2.1 3.1 4.12 5.51 6.36 11.54 12.19 16.67)) predict(outcome(5))
	margins if v_worker==1, at(worker=(0 1 2.1 3.1 4.12 5.51 6.36 11.54 12.19 16.67)) predict(outcome(6))
	margins if v_worker==1, at(worker=(0 1 2.1 3.1 4.12 5.51 6.36 11.54 12.19 16.67)) predict(outcome(7))
	
	margins if v_worker==0, at(worker=(0 1 2.1 3.1 4.12 5.51 6.36 11.54 12.19 16.67)) predict(outcome(1))
	margins if v_worker==0, at(worker=(0 1 2.1 3.1 4.12 5.51 6.36 11.54 12.19 16.67)) predict(outcome(2))
	margins if v_worker==0, at(worker=(0 1 2.1 3.1 4.12 5.51 6.36 11.54 12.19 16.67)) predict(outcome(3))
	margins if v_worker==0, at(worker=(0 1 2.1 3.1 4.12 5.51 6.36 11.54 12.19 16.67)) predict(outcome(4))
	margins if v_worker==0, at(worker=(0 1 2.1 3.1 4.12 5.51 6.36 11.54 12.19 16.67)) predict(outcome(5))
	margins if v_worker==0, at(worker=(0 1 2.1 3.1 4.12 5.51 6.36 11.54 12.19 16.67)) predict(outcome(6))
	margins if v_worker==0, at(worker=(0 1 2.1 3.1 4.12 5.51 6.36 11.54 12.19 16.67)) predict(outcome(7))
	

*Figure B3 Working-Class Representation and Legislative Accomplishment
meologit ec4 c.workers##i.v_worker  pers_vote pid_left gni  ed pol_intr income_full female i.b0.ideology5 age rural econ_worse i.married || cyear:, covar(un);
	margins if v_worker==1, at(worker=(0 1 2.1 3.1 4.12 5.51 6.36 11.54 12.19 16.67)) predict(outcome(1))
	margins if v_worker==1, at(worker=(0 1 2.1 3.1 4.12 5.51 6.36 11.54 12.19 16.67)) predict(outcome(2))
	margins if v_worker==1, at(worker=(0 1 2.1 3.1 4.12 5.51 6.36 11.54 12.19 16.67)) predict(outcome(3))
	margins if v_worker==1, at(worker=(0 1 2.1 3.1 4.12 5.51 6.36 11.54 12.19 16.67)) predict(outcome(4))
	margins if v_worker==1, at(worker=(0 1 2.1 3.1 4.12 5.51 6.36 11.54 12.19 16.67)) predict(outcome(5))
	margins if v_worker==1, at(worker=(0 1 2.1 3.1 4.12 5.51 6.36 11.54 12.19 16.67)) predict(outcome(6))
	margins if v_worker==1, at(worker=(0 1 2.1 3.1 4.12 5.51 6.36 11.54 12.19 16.67)) predict(outcome(7))
	
	margins if v_worker==0, at(worker=(0 1 2.1 3.1 4.12 5.51 6.36 11.54 12.19 16.67)) predict(outcome(1))
	margins if v_worker==0, at(worker=(0 1 2.1 3.1 4.12 5.51 6.36 11.54 12.19 16.67)) predict(outcome(2))
	margins if v_worker==0, at(worker=(0 1 2.1 3.1 4.12 5.51 6.36 11.54 12.19 16.67)) predict(outcome(3))
	margins if v_worker==0, at(worker=(0 1 2.1 3.1 4.12 5.51 6.36 11.54 12.19 16.67)) predict(outcome(4))
	margins if v_worker==0, at(worker=(0 1 2.1 3.1 4.12 5.51 6.36 11.54 12.19 16.67)) predict(outcome(5))
	margins if v_worker==0, at(worker=(0 1 2.1 3.1 4.12 5.51 6.36 11.54 12.19 16.67)) predict(outcome(6))
	margins if v_worker==0, at(worker=(0 1 2.1 3.1 4.12 5.51 6.36 11.54 12.19 16.67)) predict(outcome(7))
		
*Table B1 Robustness Check, Governance Quality 
meologit leg_approve workers   pers_vote pid_left wgi   ed pol_intr income_full female i.b0.ideology5 age rural econ_worse i.married if year<=2010 || cyear:, covar(un)
meologit leg_approve c.workers##i.v_worker   pers_vote pid_left wgi   ed pol_intr income_full female i.b0.ideology5 age rural econ_worse i.married || cyear:, covar(un)
meologit b13 workers  pers_vote pid_left wgi   ed pol_intr  income_full female i.b0.ideology5 age rural econ_worse i.married if year<=2010 || cyear:, covar(un)
meologit b13 c.workers##i.v_worker   pers_vote pid_left wgi   ed pol_intr income_full female i.b0.ideology5 age rural econ_worse i.married || cyear:, covar(un)
meologit ec4 workers   pers_vote pid_left wgi    ed pol_intr income_full female i.b0.ideology5 age rural econ_worse i.married if year<=2010 || cyear:, covar(un)
meologit ec4 c.workers##i.v_worker   pers_vote pid_left wgi   ed pol_intr income_full female i.b0.ideology5 age rural econ_worse i.married || cyear:, covar(un)
	
*Table B2 Robustness Check, Level of Democracy	
meologit leg_approve workers  pers_vote pid_left democracy   ed pol_intr income_full female i.b0.ideology5 age rural econ_worse i.married if year<=2010 || cyear:, covar(un)
meologit leg_approve c.workers##i.v_worker  pers_vote pid_left democracy ed pol_intr income_full female i.b0.ideology5 age rural econ_worse i.married || cyear:, covar(un)
meologit b13 workers  pers_vote pid_left democracy   ed pol_intr  income_full female i.b0.ideology5 age rural econ_worse i.married if year<=2010 || cyear:, covar(un)
meologit b13 c.workers##i.v_worker  pers_vote pid_left democracy ed pol_intr income_full female i.b0.ideology5 age rural econ_worse i.married || cyear:, covar(un)
meologit ec4 workers  pers_vote pid_left democracy    ed pol_intr income_full female i.b0.ideology5 age rural econ_worse i.married if year<=2010 || cyear:, covar(un)
meologit ec4 c.workers##i.v_worker  pers_vote pid_left democracy ed pol_intr income_full female i.b0.ideology5 age rural econ_worse i.married || cyear:, covar(un)


*Table B3 Robustness Check, Left-Parties from PELA Self-Placement Question
eststo clear
eststo: meologit leg_approve workers pers_vote lid_left gni   ed pol_intr income_full female i.b0.ideology5 age rural econ_worse i.married if year<=2010 || cyear:, covar(un)
eststo: meologit leg_approve c.workers##i.v_worker pers_vote lid_left gni  ed pol_intr income_full female i.b0.ideology5 age rural econ_worse i.married || cyear:, covar(un)
eststo: meologit b13 workers  pers_vote lid_left gni   ed pol_intr  income_full female i.b0.ideology5 age rural econ_worse i.married if year<=2010 || cyear:, covar(un)
eststo: meologit b13 c.workers##i.v_worker pers_vote lid_left gni  ed pol_intr income_full female i.b0.ideology5 age rural econ_worse i.married || cyear:, covar(un)
eststo: meologit ec4 workers   pers_vote lid_left gni    ed pol_intr income_full female i.b0.ideology5 age rural econ_worse i.married if year<=2010 || cyear:, covar(un)
eststo: meologit ec4 c.workers##i.v_worker pers_vote lid_left gni  ed pol_intr income_full female i.b0.ideology5 age rural econ_worse i.married || cyear:, covar(un)


*Table B4 Robustness Check, Left-President	
meologit leg_approve workers pers_vote pres_ideo gni   ed pol_intr income_full female i.b0.ideology5 age rural econ_worse i.married if year<=2010 || cyear:, covar(un)
meologit leg_approve c.workers##i.v_worker pers_vote pres_ideo gni  ed pol_intr income_full female i.b0.ideology5 age rural econ_worse i.married || cyear:, covar(un)
meologit b13 workers  pers_vote pres_ideo gni   ed pol_intr  income_full female i.b0.ideology5 age rural econ_worse i.married if year<=2010 || cyear:, covar(un)
meologit b13 c.workers##i.v_worker pers_vote pres_ideo gni  ed pol_intr income_full female i.b0.ideology5 age rural econ_worse i.married || cyear:, covar(un)
meologit ec4 workers   pers_vote pres_ideo gni    ed pol_intr income_full female i.b0.ideology5 age rural econ_worse i.married if year<=2010 || cyear:, covar(un)
meologit ec4 c.workers##i.v_worker pers_vote pres_ideo gni  ed pol_intr income_full female i.b0.ideology5 age rural econ_worse i.married || cyear:, covar(un)

*Table B5 Robustness Check, Personal Vote-Seeking Incentives Interaction	
meologit leg_approve c.workers##c.pers_vote pid_left gni  ed pol_intr income_full female i.b0.ideology5 age rural econ_worse i.married if year<=2010|| cyear:, covar(un)
meologit b13 c.workers##c.pers_vote pid_left gni  ed pol_intr income_full female i.b0.ideology5 age rural econ_worse i.married if year<=2010|| cyear:, covar(un)
meologit ec4 c.workers##c.pers_vote pid_left gni  ed pol_intr income_full female i.b0.ideology5 age rural econ_worse i.married if year<=2010|| cyear:, covar(un)

*Table B.6 Working-Class Rep. and Perceptions of Leg., Control for Programmatic Parties
meologit leg_approve workers  psi_vdem pid_left gni  ed pol_intr income_full female i.b0.ideology5 age rural econ_worse i.married if year<=2010 || cyear:, covar(un)
meologit leg_approve c.workers##i.v_worker  psi_vdem pid_left gni   ed pol_intr income_full female i.b0.ideology5 age rural econ_worse i.married || cyear:, covar(un)
meologit b13 workers  psi_vdem pid_left gni  ed pol_intr  income_full female i.b0.ideology5 age rural econ_worse i.married if year<=2010 || cyear:, covar(un)
meologit b13 c.workers##i.v_worker  psi_vdem pid_left gni   ed pol_intr  income_full female i.b0.ideology5 age rural econ_worse i.married || cyear:, covar(un)
meologit ec4 workers   psi_vdem pid_left gni   ed pol_intr income_full female i.b0.ideology5 age rural econ_worse i.married if year<=2010 || cyear:, covar(un)
meologit ec4 c.workers##i.v_worker  psi_vdem pid_left gni   ed pol_intr  income_full female i.b0.ideology5 age rural econ_worse i.married || cyear:, covar(un)


*Table B.7 Working-Class Rep, Perceptions of the Legislature, & Party System Fragmentation=
meologit leg_approve workers   party_frag pid_left gni  ed pol_intr income_full female i.b0.ideology5 age rural econ_worse i.married if year<=2010 || cyear:, covar(un)
meologit leg_approve c.workers##i.v_worker  party_frag pid_left gni  ed pol_intr income_full female i.b0.ideology5 age rural econ_worse i.married || cyear:, covar(un)
meologit b13 workers  party_frag pid_left gni   ed pol_intr  income_full female i.b0.ideology5 age rural econ_worse i.married if year<=2010 || cyear:, covar(un)
meologit b13 c.workers##i.v_worker  party_frag pid_left gni  ed pol_intr income_full female i.b0.ideology5 age rural econ_worse i.married || cyear:, covar(un)
meologit ec4 workers   party_frag pid_left gni    ed pol_intr income_full female i.b0.ideology5 age rural econ_worse i.married if year<=2010 || cyear:, covar(un)
meologit ec4 c.workers##i.v_worker  party_frag pid_left gni  ed pol_intr income_full female i.b0.ideology5 age rural econ_worse i.married || cyear:, covar(un)


*Table B.9 Working-Class Representation and Perceptions of Representation, Linear Model
mixed leg_approve workers pers_vote pid_left gni  ed pol_intr income_full female i.b0.ideology5 age rural econ_worse i.married if year<=2010 || cyear:, covar(un)
mixed leg_approve c.workers##i.v_worker pers_vote pid_left gni  ed pol_intr income_full female i.b0.ideology5 age rural econ_worse i.married  || cyear:, covar(un)
mixed b13 workers  pers_vote pid_left gni  ed pol_intr  income_full female i.b0.ideology5 age rural econ_worse i.married if year<=2010 || cyear:, covar(un)
mixed b13 c.workers##i.v_worker  pers_vote pid_left gni  ed pol_intr  income_full female i.b0.ideology5 age rural econ_worse i.married || cyear:, covar(un)
mixed ec4 workers  pers_vote pid_left gni ed pol_intr income_full female i.b0.ideology5 age rural econ_worse i.married if year<=2010 || cyear:, covar(un)
mixed ec4 c.workers##i.v_worker pers_vote pid_left gni  ed pol_intr income_full female i.b0.ideology5 age rural econ_worse i.married || cyear:, covar(un)
